home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2009 February / PCWFEB09.iso / Software / Resources / Security / McAfee SiteAdvisor 26.6 / safe.xpi / chrome / safe.jar / content / main.js < prev    next >
Text File  |  2007-12-04  |  12KB  |  259 lines

  1. /*-----------------------------------------------------
  2.   Copyright (c) 2006 McAfee, Inc.  All Rights Reserved.
  3.   -----------------------------------------------------*/
  4. var upscale = 1.0;
  5. var arrowheight=34;
  6. var arrowwidth =35;
  7. var borderheight=200;
  8. var borderwidth=286*upscale;
  9. var iconwidth=16;
  10. var iconheight=16;
  11. var hedge = 30; // edge of arrow to edge of bubble
  12. var scrollbarwidth = 20;
  13. var vpadding = 9;
  14. var hpadding = Math.round(5*upscale);
  15. var bubblecorner = 11*upscale;
  16.  
  17. var color;
  18.  
  19. document.onmousemove = MoveBubble;
  20. window.addEventListener("DOMMouseScroll",shut, false);
  21.  
  22. var ct=0;
  23. var mv=0;
  24.  
  25. function setScale(locscale) {
  26.     upscale = locscale;
  27.     borderwidth = 286*upscale;
  28.     hpadding = Math.round(5*upscale);
  29.     bubblecorner = 11*upscale;
  30. }
  31. function _overflow(e) {
  32.     if (e.currentTarget.id != "linktitdiv") return;
  33.     var obj = e.currentTarget;
  34.     obj.ins = document.createElement("ins");
  35.     obj.ins.innerHTML="\u2026";
  36.     obj.ins.setAttribute("style","position:absolute;right:0;text-align:right;padding-right:.9em;text-decoration:none;");
  37.     obj.appendChild(obj.ins);
  38. }
  39. function _underflow(e) {
  40.     if (e.currentTarget.id != "linktitdiv") return;
  41.     var obj = e.currentTarget;
  42.     if (obj.ins) obj.ins.innerHTML = "";
  43. }
  44.  
  45.  
  46. function pop(e,domain,verdict,overall,image1,image2,image3,desc1,desc2,desc3,link1,link2,col,linktitenc,locscale) {
  47.  
  48.     setScale(locscale);
  49.     if (typeof(linktitenc) == 'undefined') linktitenc = domain;
  50.  
  51.  
  52.     if (contains(document.getElementById('stickytable'),e.relatedTarget))
  53.         return;
  54.  
  55.     color = col;
  56.     bdcolor = "white";
  57.     switch (color) {
  58.         case "green":
  59.             bdcolor = "#3BA671";
  60.             break;
  61.         case "red":
  62.             bdcolor = "#E47F97";
  63.             break;
  64.         case "yellow":
  65.             bdcolor = "#FFDD55";
  66.             break;
  67.         case "white":
  68.             bdcolor = "#999999";
  69.         default:
  70.             break;
  71.     }
  72.       document.getElementById("BorderLayer").style.backgroundImage = "none";
  73.     document.getElementById("border_bg_image").src = "chrome://safe/content/" + color + "bubble.gif";
  74.  
  75.     var closex="<TD ALIGN='right' style='border-bottom: 1px solid "+bdcolor+";padding-bottom:.2em;font-size:medium;'><img ONCLICK='BubbleHide()' style='height:0.8764em;padding-right:.3em;cursor:pointer;font-size:medium;'  id='closebutton' border=0 onmouseout=\"document.getElementById('closebutton').src='chrome://safe/content/xup.gif';\" onmouseup=\"document.getElementById('closebutton').src='chrome://safe/content/xup.gif';\"  onmousedown=\"document.getElementById('closebutton').src='chrome://safe/content/xdown.gif';\"  src='chrome://safe/content/xup.gif'/></TD>";
  76.     var title = "<TABLE  WIDTH='100%' BORDER='0' CELLPADDING='0' CELLSPACING='0' style='border-bottom:1px solid white;'><TR VALIGN='MIDDLE'><TD ALIGN='LEFT' style='border-bottom: 1px solid "+bdcolor+";padding-bottom:.2em;font-size:medium;'><img style='padding-left:.3em;height:.939em;font-size:medium;' src='chrome://safe/content/mc"+color+".gif'/></TD>"+closex+"</TR></TABLE>";
  77.  
  78.     bod = "<style type=\"text/css\">ins{background:url(chrome://safe/content/"+color.charAt(0)+".png) repeat;}</style><div id=\"linktitdiv\" class='sastyle_div_headline' style=\"padding-left:.8em;padding-right:.8em;white-space:nowrap;overflow:hidden;color:black;\"></div><span class='sastyle_text_domainname' style='margin-top:6px;margin-bottom:10px;padding-left:.8em;padding-right:.8em;color:black;'>" + domain + "</span><br/><p class='sastyle_text_overallrec' style='padding-left:.8em;padding-right:.8em;float:none;margin-top:8px;line-height:13px;color:black;'>"+overall+"</p>";
  79.     var links = "";
  80.     if (verdict != "Untested.") {
  81.         bod += "<tr><td valign=center width='100%' style='padding-left:.5em;padding-right:.5em;'><div style='background:url(chrome://safe/content/"+color.charAt(0)+
  82.         "ul.png) 0 0 repeat-x;'><div style='background:url(chrome://safe/content/"+color.charAt(0)+
  83.         "ul.png) 0 100% repeat-x;'><div style='background:url(chrome://safe/content/"+color.charAt(0)+
  84.         "l.png) 0 0 repeat-y;'><div style='background:url(chrome://safe/content/"+color.charAt(0)+
  85.         "r.png) 100% 0 repeat-y;'><div style='background:url(chrome://safe/content/"+color.charAt(0)+
  86.         "llc.png) 0 100% no-repeat;'><div style='background:url(chrome://safe/content/"+color.charAt(0)+
  87.         "lrc.png) 100% 100% no-repeat;'><div style='background:url(chrome://safe/content/"+color.charAt(0)+
  88.         "ulc.png) 0 0 no-repeat;'><div style='background:url(chrome://safe/content/"+color.charAt(0)+
  89.         "urc.png) 100% 0 no-repeat;'><table width='100%'><tr ><td align='left' style='padding:.1em;width:.8512em;' >" + image1 +
  90.         "</td><td align='left'  style='padding:.1em;' colspan='2'><font class='sastyle_text_facetrec' style='color:black;'>" +
  91.         desc1 + "</font></td></tr><tr><td align='left' style='padding:.1em;width:.8512em;'>" + image2 +
  92.         "</td><td align='left' style='padding:.1em;' colspan='2' ><font class='sastyle_text_facetrec' style='color:black;'>" + desc2 +
  93.         "</font></td></tr><tr ><td align='left' style='padding:.1em;width:.8512em;'>" + image3 +
  94.         "</td><td align='left' style='padding:.1em;'><font class='sastyle_text_facetrec' style='color:black;'>" + desc3 +
  95.         "</font></td><td align='right' style=''>"+link1+"</td></tr></table></div></div></div></div></div></div></div></div></td></tr>";
  96.         links = "<table style='table-layout:fixed;' width=100%><tr width=100%><td width=100% style='' align='right'>" + link2 + "</td></tr></table>";
  97.     } else
  98.         links = "<table style='table-layout:fixed;' width=100%><tr width=100%><td style='' align='right'>" + link2 + "</td></tr></table>";
  99.  
  100.  
  101.  
  102.     var hypertxt="<span id='"+ domain + "'></span><TABLE style='font-size:medium;font-color:black;table-layout:fixed' id='stickytable' WIDTH='100%' HEIGHT='100%' BORDER='0' CELLPADDING='0' CELLSPACING='0'><TR VALIGN=TOP><TD style=''>"+title+"</TD></TR><TR VALIGN=TOP style='overflow:hidden'><TD style='' VALIGN=TOP>"+bod+"</TD></TR><TR VALIGN=BOTTOM><TD style=''>" + links + "</TD></TR></TABLE>"
  103.  
  104.  
  105.     document.getElementById("BubbleLayer").innerHTML=hypertxt;
  106.     document.getElementById("linktitdiv").addEventListener("overflow", _overflow, false);
  107.     document.getElementById("linktitdiv").addEventListener("underflow", _underflow, false);
  108.         document.getElementById("linktitdiv").innerHTML = linktitenc;
  109.  
  110.  
  111.     ct=0;
  112.     mv=1;
  113.     icon = e.currentTarget;
  114.  
  115.  
  116.     document.getElementById('BorderLayer').onmouseout = shut;
  117.      document.getElementById('InvLayer').onmouseout = shut;
  118.     document.getElementById('ArrowLayer').onmouseout = shut;
  119.     document.getElementById('BubbleLayer').onmouseout = shut;
  120. }
  121.  
  122. function contains (container, containee) {
  123.   while (containee) {
  124.     if (container == containee) {
  125.       return true;
  126.     }
  127.     containee = containee.parentNode;
  128.   }
  129.   return false;
  130. }
  131.  
  132. function MoveBubble(e) {
  133.     if(mv) {
  134.  
  135.         var arrowlayer = document.getElementById('ArrowLayer');
  136.         var bubblelayer = document.getElementById('BubbleLayer');
  137.         var borderlayer = document.getElementById('BorderLayer');
  138.         var invlayer = document.getElementById('InvLayer');
  139.         var bgimage = document.getElementById('border_bg_image');
  140.         var arrowimage = document.getElementById('arrow_bg_image');
  141.  
  142.  
  143.         arrowlayer.style.width = arrowwidth*.0626 + "em";
  144.         arrowlayer.style.height = arrowheight*.0626 + "em";
  145.         borderlayer.style.width = borderwidth*.0626 + "em";
  146.         borderlayer.style.height = borderheight*.0626 + "em";
  147.         invlayer.style.width = borderwidth*.0626 + "em";
  148.         invlayer.style.height = arrowheight*.0626 + "em";
  149.         bgimage.style.width = borderlayer.style.width;
  150.         bgimage.style.height = borderlayer.style.height;
  151.         arrowimage.style.width = arrowlayer.style.width;
  152.         arrowimage.style.height = arrowlayer.style.height;
  153.         growth_factor = bgimage.height / 200.0;
  154.  
  155.         var baseX = OffsetLeft(icon) + iconwidth*growth_factor / 2; // middle of the icon
  156.         var baseY = OffsetTop(icon); // top of the icon
  157.         if (baseY - arrowheight*growth_factor - borderheight*growth_factor > window.pageYOffset) {  // upright
  158.             arrowlayer.style.backgroundImage = "none";
  159.             arrowimage.src = "chrome://safe/content/" + color + "downarrow.gif";
  160.             arrowlayer.style.top = (baseY - arrowheight*growth_factor) + "px";
  161.             borderlayer.style.top = (baseY - arrowheight*growth_factor - borderheight*growth_factor) + "px";
  162.             invlayer.style.top = (OffsetTop(borderlayer) + borderheight*growth_factor) + "px";
  163.         } else { // upside-down
  164.             arrowlayer.style.backgroundImage = "none";
  165.             arrowimage.src = "chrome://safe/content/" + color + "uparrow.gif";
  166.             arrowlayer.style.top = (baseY + iconheight*growth_factor) + "px";
  167.             borderlayer.style.top = (baseY + iconheight*growth_factor + arrowheight*growth_factor) + "px";
  168.             invlayer.style.top = (OffsetTop(borderlayer) - arrowheight*growth_factor) + "px";
  169.         }
  170.  
  171.  
  172.         if (baseX + (borderwidth*growth_factor - hedge*growth_factor) < window.pageXOffset + window.innerWidth-scrollbarwidth) { // not h-clipped
  173.             arrowlayer.style.left = baseX + "px";
  174.             borderlayer.style.left = (baseX - hedge*growth_factor) + "px";
  175.  
  176.         } else { // need to slide borderlayer
  177.             borderlayer.style.left = (window.pageXOffset + window.innerWidth - borderwidth*growth_factor-scrollbarwidth) + "px";
  178.             if (baseX + arrowwidth*growth_factor > window.pageXOffset + window.innerWidth - scrollbarwidth)
  179.                 arrowlayer.style.left = (window.pageXOffset + window.innerWidth - arrowwidth*growth_factor-scrollbarwidth-bubblecorner*growth_factor) + "px";
  180.             else
  181.                 arrowlayer.style.left = baseX + "px";
  182.         }
  183.  
  184.         bubblelayer.style.top = (OffsetTop(borderlayer) + vpadding*growth_factor) + "px";
  185.         bubblelayer.style.left = (OffsetLeft(borderlayer) + hpadding*growth_factor) + "px";
  186.         bubblelayer.style.width = (borderwidth - 2*hpadding)*.0626 + "em";
  187.         bubblelayer.style.height = (borderheight - 2*vpadding)*.0626 + "em";
  188.  
  189.         invlayer.style.left = OffsetLeft(borderlayer) + "px";
  190.  
  191.         if(document.location.href.match(/(suche\.web\.de)|(suche\.gmx\.net)|(\.live\.)|(\.google\.)|(\.cox\.net)|(\.goo\.)|(\.msn\.)/))
  192.         {
  193.             bubblelayer.style.zIndex = 99999;
  194.             invlayer.style.zIndex = 99999;
  195.             arrowlayer.style.zIndex = 99999;
  196.             borderlayer.style.zIndex = 99999;            
  197.         }
  198.         
  199.         ShowBubble();
  200.     }
  201. }
  202.  
  203. function OffsetTop(elm) {
  204.     var t = elm.offsetTop;
  205.     while (elm.offsetParent) {
  206.         elm = elm.offsetParent;
  207.         t += elm.offsetTop;
  208.     }
  209.     return t;
  210. }
  211.  
  212. function OffsetLeft(elm) {
  213.     var l = elm.offsetLeft;
  214.     while (elm.offsetParent) {
  215.         elm = elm.offsetParent;
  216.         l += elm.offsetLeft;
  217.     }
  218.     return l;
  219. }
  220.  
  221.  
  222. function ShowBubble() {
  223.       ct++
  224.     if(ct == 1) {
  225.          document.getElementById("BubbleLayer").style.visibility= 'visible';
  226.          document.getElementById('BorderLayer').style.visibility='visible';
  227.         document.getElementById('ArrowLayer').style.visibility='visible';
  228.         document.getElementById('InvLayer').style.visibility='visible';
  229.         mv = 0;
  230.       }
  231.  
  232. }
  233.  
  234. function BubbleHide() {
  235.     document.getElementById("BubbleLayer").style.visibility='hidden';
  236.     document.getElementById("BubbleLayer").style.left=-800;
  237.     document.getElementById("BubbleLayer").style.top=-800;
  238.     document.getElementById('BorderLayer').style.visibility = 'hidden';
  239.     document.getElementById('BorderLayer').style.left=-800;
  240.     document.getElementById('BorderLayer').style.top=-800;
  241.     document.getElementById('ArrowLayer').style.visibility = 'hidden';
  242.     document.getElementById('ArrowLayer').style.left=-800;
  243.     document.getElementById('ArrowLayer').style.top=-800;
  244.     document.getElementById('InvLayer').style.visibility = 'hidden';
  245.     document.getElementById('InvLayer').style.left=-800;
  246.     document.getElementById('InvLayer').style.top=-800;
  247.  
  248. }
  249.  
  250.  
  251. function shut(e) {
  252.  
  253.     if (!contains(document.getElementById('BorderLayer'),e.relatedTarget) && !contains(document.getElementById('BubbleLayer'),e.relatedTarget) && !contains(document.getElementById('ArrowLayer'),e.relatedTarget) && !contains(document.getElementById('InvLayer'),e.relatedTarget) && typeof(icon) != "undefined" && !contains(icon,e.relatedTarget))
  254.         BubbleHide();
  255.  
  256. }
  257.  
  258. MoveBubble();
  259.